/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.techshop.dao.impl;
import com.techshop.dao.PhoneVoteDao;
import com.techshop.model.PhoneVote;
import com.techshop.util.MyUtil;
import java.util.List;
import org.hibernate.Query;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 *
 * @author Hai-PC
 */
public class PhoneVoteDaoImpl extends HibernateDaoSupport implements PhoneVoteDao {
  
    @Override
    public PhoneVote getById(int phoneVoteID)
    {
        try
        {
            return (PhoneVote) getSession().get(PhoneVote.class, phoneVoteID);
        }
        catch (DataAccessResourceFailureException e)
        {
            System.err.printf("Error: ", e.toString());
            return null;
        }
    }

    @Override
    public List<PhoneVote> findAll()
    {
        try
        {
            System.out.println("YYYYYYY");
             Query q = getSession().createQuery("from PhoneVote");
           q.setFirstResult(0);
           q.setMaxResults(50);
            return q.list();
           // return getSession().createQuery("from PhoneVote").list();
        }
        catch (DataAccessResourceFailureException e)
        {
            System.err.printf("Error: ", e.toString());
            return null;
        }
    }

    @Override
    public boolean insert(PhoneVote phoneVote) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public boolean update(PhoneVote phoneVote) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public boolean delete(PhoneVote phoneVote) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

   
}